<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
<spring:message  code="pim"/> - <spring:message  code="homepage.project"/>&nbsp;
<c:out value="${bean.project.name}"></c:out> - <spring:message  code="title.project.list.activities"/>	
</title>
<link href="<%= request.getContextPath() %>/css/custom.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/v.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/paging.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/jquery.ui.all.css" rel="stylesheet" />
<link href="<%= request.getContextPath() %>/css/jquery.ui.dialog.css" rel="stylesheet" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.6.2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-ui-1.8.14.custom.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.hint.text.js"></script>
<%@include file="script/sort-table.jsp" %>
<%@include file="script/pim-util.jsp" %>
<%@include file="script/paging-script.jsp" %>
<%@include file="script/activityLog-script.jsp" %>
<c:choose>
 <c:when test="${bean.isAdmin == true}">
  <script type="text/javascript">
    var TSort_Data = new Array ('mytable','', '','s','s', 's', 's','s');
    tsRegister();
  </script>
 </c:when>
 <c:otherwise>
   <script type="text/javascript">
    var TSort_Data = new Array ('mytable','','s','s', 's', 's','s');
    tsRegister();
  </script>
 </c:otherwise>
</c:choose>
<style type="text/css">
.input,.select {
	width: 200px;
}
.ui-button,.ui-button-text {
    display: inline !important;
    line-height: 0 !important;
}
</style>
</head>
<body>
<% try{ %>
<c:if test="${bean.isSigned == true}">
<div id="all">
	<div id="wrapper">
	<div id="mainheader">
		<jsp:include page="include/common/headerSignedIn.jsp" />
	</div> 
	<div id="content-wrapper">
	<div id="top-menu">
	    <jsp:include page="include/common/topMenuHome.jsp" />
	</div>
	<div class="workspace-menu-top">
	   <c:choose>
	    <c:when test="${bean.isAdmin == true}">
	      <jsp:include page="include/common/admin-menu.jsp" />
	    </c:when>
	    <c:otherwise>
	      <jsp:include page="include/common/user-menu.jsp" />
	    </c:otherwise>
	   </c:choose>    
	</div> 
	<div id="removeActivitiesDialog" style="height: 20px !important;" ></div>
	<form:form method="post" action="" commandName="activityLogQuery" name="activityLogForm">
	<c:if test="${bean.isAdmin == true}">
	  <div class="v-row" style="padding: 20px;">  
		  <table>
		    <tr>
		        <td style="color:black;"><spring:message code="activity.log.label.keyword"/></td>             
		        <td><form:input  path="searchKey" cssClass="input" title="Keyword..."/></td>      
		        <td style="color:black;"><spring:message code="activity.log.label.search.by"/></td>        
		        <td>
		           <form:select path="title" cssClass="select">
		             <form:option value="Name"><spring:message code="Name"/></form:option>
		             <form:option value="Visa"><spring:message code="Visa"/></form:option>
		             <form:option value="Any"><spring:message code="Any"/></form:option>
		           </form:select>
		        </td>    
		    </tr>
		    <tr>
		        <td style="color:black;"><spring:message code="activity.log.label.item.type"/></td>
		        <td>
		            <form:select path="itemType" cssClass="select">
		              <form:option value=""><spring:message code="please.choice"/></form:option>
		              <form:option value="Task"><spring:message code="Task"/></form:option>
		            </form:select>		            
		        </td> 
		    </tr>  
		    <tr>
		        <td style="color:black;"><spring:message code="activity.log.label.action.type"/></td>
		        <td>
		          <form:select path="actionType" cssClass="select">
		            <form:option value=""><spring:message code="please.choice"/></form:option>
		            <form:option value="Create"><spring:message code="Create"/></form:option>
		            <form:option value="Update"><spring:message code="Update"/></form:option>
		            <form:option value="Delete"><spring:message code="Delete"/></form:option>
		          </form:select>		        
		        </td> 
		    </tr>      
		    <tr>
		        <td style="color:black;"><spring:message code="activity.log.label.from"/></td>             
		        <td><form:input path="from" onkeypress="return isDateKey(event)" cssClass="input"/></td>   
		    </tr>
		    <tr>
		        <td style="color:black;"><spring:message code="activity.log.label.to"/></td>             
		        <td>                
		           <form:input path="to" onkeypress="return isDateKey(event)" cssClass="input"/> 
		           <input type="button" class="bt-form" name="searchActivityLogs" value="<spring:message  code="search"/>"/> 
		        </td> 
		    </tr>
		    <tr>
		      <td colspan="2">
		        <div class="check-date"><span class="v-error-message"></span></div>
		      </td>
		    </tr>
		  </table>
	  </div>
	 
	  <div class="v-row" id="v-global-message">
		<c:if test="${removeOK == true }">
	       <span class="v-global-success-message v-row">
	           <span><spring:message code="activity.log.remove.success" arguments="${deletedItems}"/></span>
	       </span>
		</c:if>
	    <c:if test="${removeOK == false }">
	      <span class="v-global-error-message v-row">        
	          <span><spring:message code="activity.log.remove.error"/></span>     
	      </span>
	    </c:if>
	  </div>
	 </c:if>
	 
	  <div class="v-row" style="padding-top: 15px;">
	  <table class="v-table" id="mytable">
	    <thead>
	      <tr class="v-table-header">
	        <c:if test="${bean.isAdmin == true}">
	        <th style="width: 5%;"><input type="checkbox" class="ckbSelectAll" value="0"/></th>
	        </c:if>
	        <th style="width: 5%;"><spring:message code = "activity.log.label.no"/></th>
	        <th style="width: 10%;"><spring:message code = "activity.log.label.action.type"/></th>
	        <th style="width: 10%;"><spring:message code = "activity.log.label.item.type"/></th>
	        <th style="width: 40%;"><spring:message code = "activity.log.label.item.name"/></th>        
	        <th style="width: 10%;"><spring:message code = "activity.log.label.visa"/></th>
	        <th style="width: 15%;"><spring:message code = "activity.log.label.date"/></th>
	      </tr>
	    </thead>
	    <tbody>
	     <c:choose>
	      <c:when test="${bean.countList == 0}">
			<tr>
				<td colspan="${bean.isAdmin == true?'7':'6'}" class="v-warning-message">
					<spring:message code="search.empty" />
				</td>
			</tr>
		  </c:when>
		 </c:choose>   	      
	      <c:forEach items="${bean.activityLogs}" var="activity" varStatus="count">
	        <tr class="${count.count % 2 != 0 ? 'v-table-row-0' : 'v-table-row-1'}">
	          <c:if test="${bean.isAdmin == true}">
	          <td style="text-align: center;" scope="row"><form:checkbox cssClass="ckbChild" path="activityLogIds" value="${activity.activityLogId}"/></td>
	          </c:if>
	          <td class="v-number-cell" scope="row"><c:out value="${count.count + ( bean.paging.currentPage - 1 ) * bean.paging.pageSize}"/></td>
	          <td class="v-text-cell" scope="row"><spring:message code = "${activity.message}"/></td>
	          <td class="v-text-cell" scope="row"><spring:message code = "${activity.subjectType}"/></td>
	          <td class="v-text-cell" scope="row"><a href="taskDetail.htm?pnum=${bean.pnum}&tcode=${activity.subjectId}" style="text-decoration: none;">${activity.subjectName}</a></td>                    
	          <td class="v-text-cell" scope="row">${activity.createdBy}</td>        
	          <td class="v-text-cell" scope="row"><fmt:formatDate pattern="yyyy-MM-dd hh:mm" value="${activity.createdAt}"/></td>
	        </tr>
	      </c:forEach>
	    </tbody>
	  </table>        
	  </div>
	
	  <div class="v-row">
	   <c:if test="${bean.countList > 0 && bean.isAdmin == true}">	    
	    <div class="v-row-left">                
	      <input type="button" class="bt-form" name="removeActivityLogs" value="<spring:message  code="button.delete"/>"/>    
	    </div>   
	  </c:if>   
	  </div>
	  
	   <c:if test="${bean.total > bean.itemsPerPage}">
		<div id="paging" class="v-row" style="margin-bottom: 20px;">
			<c:set value="${bean.paging}" var="paging"></c:set>
			<%@ include file="include/common/pagination.jsp"%>
		</div>		
	   </c:if>
	    
	  <div>
	    <input type="hidden" name="total" value="${bean.countList}"/>
	    <input type="hidden" name="cmd"/>
	  </div>  
	</form:form>
	</div>
	</div>
<div class="footer">
	<jsp:include page="include/common/footer.jsp" />
</div>
</div>
</c:if>
<% } catch(RuntimeException re){ re.printStackTrace(); } %>
</body>
</html>
